package com.yx.fmmall.controller;

import com.yx.fmmall.entity.PersonManager;
import com.yx.fmmall.entity.User;
import com.yx.fmmall.service.UserService;
import com.yx.fmmall.vo.ResultVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Classname UserController
 * @Date 2022/01/16 21:25
 * @Author by yx
 * @Description :
 */
@RestController
@RequestMapping("/user")
@Api(value = "登录注册接口", tags = "用户登录")
public class UserController {

    @Autowired
    private UserService userService;

    @ApiOperation("用户登录接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "string", name = "username", value = "用户登录账号", required = true),
            @ApiImplicitParam(dataType = "string", name = "password", value = "用户登录密码", required = true)
    })
    @GetMapping("/login")
    public ResultVO login(@RequestParam("username") String username, @RequestParam("password") String password) {
        return userService.checkLogin(username, password);
    }

    @PostMapping("/register")
    @ApiOperation("用户注册接口")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "string", name = "username", value = "用户注册账号", required = true),
            @ApiImplicitParam(dataType = "string", name = "password", value = "用户注册密码", required = true)
    })
    public ResultVO register(String username, String password) {
        return userService.userResgit(username, password);
    }

}
